package tech.aistar.mapper.center;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.UserInfo;

import java.util.List;

/**
 * Created by 23827 on 2019/9/27.
 */
public interface UserInfoMapper {

    @Select("select * from user_info where id = #{value}")
    UserInfo ById(Integer id);

//    查询所有
    @Select("select * from user_info")
    List<UserInfo> findAll();

//    通过用户名查找
    @Select("select * from user_info where name=#{value}")
    UserInfo findByName(String name);


//    更改信息
//    name = #{name},
//    id_card=#{idCard},
//    picture_id = #{pictureId},
//    address_id = #{addressId},
//    tel_number = #{telNumber},
//    intro = #{intro},
//    comment_id = #{commentId},
//    grade = #{grade},
//    status = #{status},
//    balance = #{balance}
//

    @Update("update user_info set name = #{name}, id_card=#{idCard}, picture_id = #{pictureId}, address_id = #{addressId},tel_number = #{telNumber},intro = #{intro},comment_id = #{commentId}, grade = #{grade}, status = #{status}, balance = #{balance} where id = #{id}")
    void updateUserInfo(UserInfo userInfo);

//    添加
    @Insert("insert into user_info(user_id,name,id_card,picture_id,address_id,tel_number,intro,comment_id,grade,status,balance,sname)values(#{userId},#{name},#{idCard},#{pictureId},#{addressId},#{telNumber},#{intro},#{commentId},#{grade},#{status},#{balance},#{sname})")
    void insertUserInfo(UserInfo userInfo);


//    通过id查询所有
    @Select("select * from user_info where id=#{value}")
    List<UserInfo> getById(Integer id);


    //通过id查找用户姓名
    @Select("select name from user_info where id = #{value}")
    UserInfo findById(Integer id);


    //通过id修改电话号码
    @Update("update user_info set tel_number = #{telNumber} where id = #{id}")
    void updateById(UserInfo userInfo);

    //通过id查找电话号码
    @Select("select tel_number from user_info where id = #{value} ")
    UserInfo findNumberById(Integer id);


    @Select("select * from user_info where user_id=#{value}")
    UserInfo getByUserId(Integer id);


//    修改部分
    void updateOne(UserInfo userInfo);




}
